#ifndef INC_PLACECOMMAND_H
#define INC_PLACECOMMAND_H

#include "Command.h"
#include "../model/UMLDiagram.h"

#include <boost/scoped_ptr.hpp>

class UMLCanvas;

class PlaceCommand : public Command
{
	public:
		PlaceCommand(UMLDiagram&, UMLCanvas&, const UMLObject&);
		PlaceCommand(const PlaceCommand&);
		
		/* Need copy constructor since scoped_ptr does not provide one. Don't
		 * need destructor though, scoped_ptr takes care of that. */

		/*** ACCESSORS ***/

		UMLObject& prototype();

		/**
		 * Places a clone of the prototype onto the diagram. If execute() is
		 * called multiple times without an intervening unexecute(), any changes
		 * made to the prototype will simply be copied to the clone currently on
		 * the diagram.
		 */
		void execute();

		void unexecute();

		const char* name() const;

	private:
		// we do not own these pointers
		UMLDiagram& _diagram;
		UMLCanvas& _canvas;

		boost::scoped_ptr<UMLObject> _prototype;

		// Invariant: if _executed is true, _created is non-NULL
		UMLObject* _created; // init-checked
		bool _executed;
};

#endif // INC_PLACECOMMAND_H
